import matplotlib.pyplot as plt

epochs = range(1, 21)  # 横坐标，表示Epoch的取值范围

train_loss = [0.3727, 0.3281, 0.3052, 0.2802, 0.2582, 0.2298, 0.1991, 0.1644, 0.1353, 0.1022, 0.0834, 0.0665, 0.0547, 0.0439, 0.0373, 0.0364, 0.0381, 0.0291, 0.0324, 0.0312]
train_acc = [82.84, 85.45, 86.325, 87.79, 88.725, 90.285, 91.655, 93.35, 94.665, 96.14, 96.99, 97.7, 98.14, 98.49, 98.675, 98.71, 98.625, 99.105, 98.925, 99.11]

valid_loss = [0.3386, 0.3329, 0.3249, 0.3316, 0.3312, 0.3337, 0.3488, 0.3746, 0.4272, 0.4853, 0.5118, 0.5562, 0.6003, 0.643, 0.683, 0.7103, 0.7167, 0.7362, 0.7485, 0.7983]
valid_acc = [84.44, 84.82, 85.34, 85.36, 85.86, 85.86, 85.38, 85.64, 85.8, 85.16, 85.04, 84.24, 85.34, 84.88, 84.92, 85.14, 84.7, 85.4, 85.14, 84.96]

plt.figure(figsize=(10, 5))
plt.subplot(1, 2, 1)  # 绘制损失曲线
plt.plot(epochs, train_loss, 'bo-', label='Training Loss')
plt.plot(epochs, valid_loss, 'ro-', label='Validation Loss')
plt.title('Training and Validation Loss')
plt.xlabel('Epochs')
plt.ylabel('Loss')
plt.xticks(range(2, 21, 2))
plt.legend()

plt.subplot(1, 2, 2)  # 绘制准确率曲线
plt.plot(epochs, train_acc, 'bo-', label='Training Accuracy')
plt.plot(epochs, valid_acc, 'ro-', label='Validation Accuracy')
plt.title('Training and Validation Accuracy')
plt.xlabel('Epochs')
plt.ylabel('Accuracy')
plt.xticks(range(2, 21, 2))
plt.legend()

plt.tight_layout()
plt.show()
